import reshandler from 'services/response-handler'
/*
 * 活动列表（通过活动类型，地域获取）
 */
 function makeData(active){
	 console.log(active)
	 if(active.activityExtDatas === undefined){
		 active.activityExtDatas = [];
	 }
        return active.activityExtDatas.map(active => {
        	let type = ''
        	switch(active.type){
        		case '0':
        		type = '抢红包'
        		break;
        		case '1':
        		type = '摇一摇'
        		break;
        		case '2':
        		type = '抽奖'
        		break;
        		case '3':
        		type = '拼团购'
        		break;
        		case '4':
        		type = 'N元抢购'
        		break;
        		case '5':
        		type = '秒杀'
        		break;
        		case '6':
        		type = '帮砍价'
        		break;
        		case '7':
        		type = '推荐有礼'
        		break;
        	}
            return {
                id:active.id || '',
                state:active.state|| '',
                type:type|| '',
                attendCount:active.attendCount|| '',
                cover:active.cover|| '',
				title:active.title || '',
				star:active.shop.star||'5',
				special:active.special || '贴膜|贴膜',
				name:active.shop.name || 'V服惠众',
				latitude: active.shop.latitude ||'',
				longitude: active.shop.longitude||''
            }
        })
    }
export default function(params,success,fail){
	alert('-------------------'+JSON.stringify(params))
	this.$.get(params)
	.then(reshandler.success(success,fail,makeData),reshandler.error(fail))
}
